<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 100px;
            height: 30px;
            border: 1px solid #000;
            position: relative;
        }
        /* 类名称为dot的div,如果内容不是空的就显示以下样式
        空格也算内容 */
        .dot:not(:empty){
            /* 块元素 */
            display: block;
            height: 15px;
            width: 15px;
            border-radius: 50%;
            background-color: red;
            /* 文字的颜色 */
            color: white;
            position: absolute;
            right: -10px;
            top: -10px;
            font-size: 12px;
            line-height: 15px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="dot">10</div>
    </div>
</body>
</html>